home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7993 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.clark.net!usenet
  2. From: yom@clark.net (yom)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: changing strings via pointers
  5. Date: 1 Mar 1996 00:33:32 GMT
  6. Organization: home
  7. Message-ID: <4h5gks$83i@clarknet.clark.net>
  8. References: <1996Feb22.125436.25503@leeds.ac.uk> <4gls59$rct@clarknet.clark.net> <4h34jv$1t4@gryphon.phoenix.net>
  9. NNTP-Posting-Host: yom.clark.net
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. On the surface, your suggestion of using strtok looks cleaner, but
  15. it comes at a *small* price.  strtok function saves a pointer (4 or
  16. 8 bytes depending on your architecture) to the byte following the 
  17. converted null byte.  I know this isn't much, but it deserves some
  18. consideration especially if you're trying to produce a high performance
  19. software.
  20.  
  21. Song (yom@clark.net)
  22.  
  23.  
  24. In article <4h34jv$1t4@gryphon.phoenix.net>, brucew@phoenix.net says...
  25. >
  26. >In comp.lang.c
  27. >yom@clark.net (yom) wrote:
  28. >
  29. >>You can use strchr string function to get the pointer to a newline
  30. >>character in your character array, and set what the pointer points
  31. >>to to NULL (0).
  32. >>
  33. >>    char *b;
  34. >>    if (b = strchr(buffer,'\n'))
  35. >>        *b = 0;
  36. >
  37. >or you could simplify and use strtok(buffer, "\n");
  38. >
  39. >
  40. >Bruce D. Wedding                        Have Compiler, Will Travel!
  41. >              Perspicacious Programming Performed Promptly
  42. >Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
  43. >
  44.  
  45.